package live.zs.fluentmybatis;

import org.mybatis.spring.SqlSessionFactoryBean;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import javax.sql.DataSource;

@SpringBootApplication
@MapperScan("live.zs.fluentmybatis.mapper")
public class FluentMybatisApplication {

    public static void main(String[] args) {
        SpringApplication.run(FluentMybatisApplication.class, args);
    }

    @Configuration
    class MybatisConfig {
        @Bean
        public SqlSessionFactoryBean sqlSessionFactoryBean(DataSource dataSource) {
            SqlSessionFactoryBean bean = new SqlSessionFactoryBean();
            bean.setDataSource(dataSource);
//            bean.setMapperLocations(new Resource[]{new ClassPathResource("mapper/MyStudentScoreMapper.xml")});
            return bean;
        }
    }
}
